local qulao_active = fk.CreateSkill {
  name = "#inker_qulao_active",
}

qulao_active:addEffect("active", {
  prompt = function(self, player, selected_cards, selected_targets)
    local prompt = next(self.skill_targets) and "#inker_qulao-invoked:::" or "#inker_qulao-invoke:::"
    local selected_num = table.reduce(selected_targets, 0, function(result, to)
      return result + self.interaction.data
    end)
    return prompt .. (self.current_num + selected_num) .. ":" .. self.num
  end,
  interaction = function(self)
    return UI.Spin{
      from = 1,
      to = self.max_num,
      default = self.max_num,
    }
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected, selected_cards)
    if not self.interaction then return false end
    local num = self.interaction.data
    if #to_select:getCardIds("he") < (self.skill_targets[tostring(to_select.id)] or 0) + num then return false end
    local selected_num = table.reduce(selected, num, function(result)
      return result + num
    end)
    return selected_num <= self.num - self.current_num
  end,
  target_tip = function(self, player, to_select, selected, selected_cards, card, selectable, extra_data)
    if not self.interaction then return end
    local actural_num = (extra_data.skill_targets[tostring(to_select.id)] or 0) + (table.contains(selected, to_select) and self.interaction.data or 0)
    if actural_num > 0 then
      return "#inker_qulao_num:::" .. actural_num
    end
  end
})

Fk:loadTranslationTable{
  ["#inker_qulao_num"] = "重铸%arg张牌",
}

return qulao_active